#include <stdlib.h>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "uzonlineprovider.h"
#include "uzonlinemain.h"
#include "authdialog.h"

#include <QDebug>
#include <QEventLoop>

//All code here is for testing
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    AuthDialog authDialog;
    if(authDialog.exec() == QDialog::Rejected) {
        //cannot use qApp->exit(), using ::exit()
        exit(0);
    }
    provider = authDialog.getProvider();
    provider->setParent(this);

    ui->setupUi(this);
    main = new UzonlineMain(this);
    connect(provider, SIGNAL(information(QHash<QString,QString>)), main, SLOT(setData(QHash<QString,QString>)));
    setCentralWidget(main);

    provider->requestData();

}

MainWindow::~MainWindow()
{
    delete ui;
}
